<template>
  <div>
    <TopNav>
      <div slot="left" class="titleBack" @click="backClick">
        <img src="../../../assets/images/common/back.svg" alt="" />
      </div>
      <div slot="center" class="title">
        <div v-for="(item, index8) in titles"
             :key="index8"
             class="title_item"
             :class="{titleColor : index8 === currentIndex}"
             @click="titleClick(index8)">
          {{item}}
        </div>
      </div>
    </TopNav>
  </div>
</template>

<script>
  import TopNav from "../../../components/common/topnav/TopNav";


  export default {
    name: "DetailTopNav",
    components: {
      TopNav
    },
    data() {
      return {
        titles: ['商品', '参数', '评论', '推荐'],
        currentIndex: 0
      }
    },
    methods: {
      titleClick(index) {
        this.currentIndex = index
        this.$emit('titleClick', index)
      },
      backClick() {
        this.$router.back()
      }
    }
  }
</script>

<style scoped>
  .title {
    display: flex;
    font-size: 14px;
    font-weight: 500;
  }
  .title_item {
    flex: 1;
  }
  .titleColor {
    color: var(--color-high-text);
  }
  .titleBack {
    /*margin-top: 10px;*/
    text-align: center;
  }
  .titleBack img {
    width: 20px;
    height: 20px;
    vertical-align: middle;
  }
</style>
